package com.swg.cocobox.filetransfer.internal;

import java.nio.charset.Charset;

import com.swg.cocobox.filetransfer.command.ReplyCommand;

final class ReplyCommandImpl implements ReplyCommand{

	private static final long serialVersionUID = 4621761735554778267L;
	
	private final int code;
	private final String message;
	private Charset encoding;
	
	public ReplyCommandImpl(Charset encoding,int code,String message) {
		this.encoding=encoding;
		this.code=code;
		this.message=message;
	}

	
	@Override
	public int getCode() {
		return code;
	}

	@Override
	public String getMessage() {
		return message;
	}
	
	@Override
	public byte[] getBytes() {
		byte[] data=null;
		String commands=null;
		StringBuilder builder=new StringBuilder();
		builder.append(code);
		builder.append(" ");
		builder.append(message);
		commands=new String(builder.toString());
		data=commands.getBytes(encoding);
		return data;
	}


	@Override
	public String toString() {
		return "ReplyCommand [code=" + code + ", message=" + message + "]";
	}
	
	

}
